<?xml version="1.0"?>
<!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database">
  <database name="default" defaultIdMethod="none">
    <table name="C_TAX">
      <column name="C_TAX_ID" primaryKey="true" required="true" type="ID" size="10" autoIncrement="false"/>
      <column name="AD_CLIENT_ID" primaryKey="false" required="true" type="ID" size="10" autoIncrement="false"/>
      <column name="AD_ORG_ID" primaryKey="false" required="true" type="ID" size="10" autoIncrement="false"/>
      <column name="ISACTIVE" primaryKey="false" required="true" type="CHAR" size="1" default="Y" autoIncrement="false"/>
      <column name="CREATED" primaryKey="false" required="true" type="TIMESTAMP" size="7" default="CURRENT_TIMESTAMP" autoIncrement="false"/>
      <column name="CREATEDBY" primaryKey="false" required="true" type="ID" size="10" autoIncrement="false"/>
      <column name="UPDATED" primaryKey="false" required="true" type="TIMESTAMP" size="7" default="CURRENT_TIMESTAMP" autoIncrement="false"/>
      <column name="NAME" primaryKey="false" required="true" type="VARCHAR" size="60" autoIncrement="false"/>
      <column name="UPDATEDBY" primaryKey="false" required="true" type="ID" size="10" autoIncrement="false"/>
      <column name="DESCRIPTION" primaryKey="false" required="false" type="VARCHAR" size="255" autoIncrement="false"/>
      <column name="TAXINDICATOR" primaryKey="false" required="false" type="VARCHAR" size="10" autoIncrement="false"/>
      <column name="ISDOCUMENTLEVEL" primaryKey="false" required="true" type="CHAR" size="1" default="Y" autoIncrement="false"/>
      <column name="VALIDFROM" primaryKey="false" required="true" type="TIMESTAMP" size="7" autoIncrement="false"/>
      <column name="ISSUMMARY" primaryKey="false" required="true" type="CHAR" size="1" default="N" autoIncrement="false"/>
      <column name="REQUIRESTAXCERTIFICATE" primaryKey="false" required="true" type="CHAR" size="1" default="N" autoIncrement="false"/>
      <column name="RATE" primaryKey="false" required="true" type="DECIMAL" autoIncrement="false"/>
      <column name="PARENT_TAX_ID" primaryKey="false" required="false" type="ID" size="10" autoIncrement="false"/>
      <column name="C_COUNTRY_ID" primaryKey="false" required="false" type="ID" size="10" autoIncrement="false"/>
      <column name="C_REGION_ID" primaryKey="false" required="false" type="ID" size="10" autoIncrement="false"/>
      <column name="TO_COUNTRY_ID" primaryKey="false" required="false" type="ID" size="10" autoIncrement="false"/>
      <column name="TO_REGION_ID" primaryKey="false" required="false" type="ID" size="10" autoIncrement="false"/>
      <column name="C_TAXCATEGORY_ID" primaryKey="false" required="true" type="ID" size="10" autoIncrement="false"/>
      <column name="ISDEFAULT" primaryKey="false" required="true" type="CHAR" size="1" default="N" autoIncrement="false"/>
      <column name="ISTAXEXEMPT" primaryKey="false" required="true" type="CHAR" size="1" default="N" autoIncrement="false"/>
      <column name="SOPOTYPE" primaryKey="false" required="true" type="CHAR" size="1" default="B" autoIncrement="false"/>
      <column name="ISSALESTAX" primaryKey="false" required="true" type="CHAR" size="1" default="N" autoIncrement="false"/>
      <foreign-key foreignTable="C_COUNTRY" name="C_COUNTRYTO_C_TAX" onDelete="none">
        <reference local="TO_COUNTRY_ID" foreign="C_COUNTRY_ID"/>
      </foreign-key>
      <foreign-key foreignTable="C_COUNTRY" name="C_COUNTRY_C_TAX" onDelete="none">
        <reference local="C_COUNTRY_ID" foreign="C_COUNTRY_ID"/>
      </foreign-key>
      <foreign-key foreignTable="C_REGION" name="C_REGION_C_TAX" onDelete="none">
        <reference local="C_REGION_ID" foreign="C_REGION_ID"/>
      </foreign-key>
      <foreign-key foreignTable="C_REGION" name="C_REGIONTO_C_TAX" onDelete="none">
        <reference local="TO_REGION_ID" foreign="C_REGION_ID"/>
      </foreign-key>
      <foreign-key foreignTable="C_TAX" name="CTAX_PARENT" onDelete="none">
        <reference local="PARENT_TAX_ID" foreign="C_TAX_ID"/>
      </foreign-key>
      <foreign-key foreignTable="C_TAXCATEGORY" name="CTAXCATEGORY_CTAX" onDelete="cascade">
        <reference local="C_TAXCATEGORY_ID" foreign="C_TAXCATEGORY_ID"/>
      </foreign-key>
      <unique name="C_TAX_KEY">
        <unique-column name="C_TAX_ID"/>
      </unique>
      <unique name="C_TAX_NAME">
        <unique-column name="AD_CLIENT_ID"/>
        <unique-column name="NAME"/>
      </unique>
      <check>
        <rule><![CDATA[IsActive in ('Y','N')]]></rule>
      </check>
      <check>
        <rule><![CDATA[IsDocumentLevel in ('Y','N')]]></rule>
      </check>
      <check>
        <rule><![CDATA[RequiresTaxCertificate in ('Y','N')]]></rule>
      </check>
    </table>
  </database>
